Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceStarter.kt renovate/net.java.dev.jna-jna-5.x (5a8f4966) Text, 2.22 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.service

Tff7b72import T7ee787android.app.ForegroundServiceStartNotAllowedException
Tff7b72import T7ee787android.content.Context
Tff7b72import T7ee787android.os.Build
Tff7b72import T7ee787androidx.work.OneTimeWorkRequestBuilder
Tff7b72import T7ee787androidx.work.OutOfQuotaPolicy
Tff7b72import T7ee787androidx.work.WorkManager
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787org.meshtastic.core.service.worker.ServiceKeepAliveWorker

T8b949e// / Helper function to start running our service
Tff7b72fun Te6edf3MeshServiceTb4b4b4.Td2a8ffCompanionTb4b4b4.Te6edf3startServiceTb4b4b4(Te6edf3contextTb4b4b4: Te6edf3ContextTb4b4b4) Tb4b4b4{
T8b949e// Before binding we want to explicitly create - so the service stays alive forever (so it can keep
T8b949e// listening for the bluetooth packets arriving from the radio. And when they arrive forward them
T8b949e// to Signal or whatever.
Te6edf3LoggerTb4b4b4.Te6edf3i Tb4b4b4{ Ta5d6ff"Ta5d6ffTrying to start service debug=Tffd700${Tff7b72falseTffd700}Ta5d6ff" Tb4b4b4}

Tff7b72val Te6edf3intent Tff7b72= Te6edf3createIntentTb4b4b4(Te6edf3contextTb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3BuildTb4b4b4.Te6edf3VERSIONTb4b4b4.Te6edf3SDK_INT Tff7b72>Tff7b72= Te6edf3BuildTb4b4b4.Te6edf3VERSION_CODESTb4b4b4.Te6edf3STb4b4b4) Tb4b4b4{
Tff7b72try Tb4b4b4{
Te6edf3contextTb4b4b4.Te6edf3startForegroundServiceTb4b4b4(Te6edf3intentTb4b4b4)
Tb4b4b4} Tff7b72catch Tb4b4b4(Te6edf3exTb4b4b4: Te6edf3ForegroundServiceStartNotAllowedExceptionTb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3w Tb4b4b4{ Ta5d6ff"Ta5d6ffUnable to start service foreground: Tffd700${Te6edf3exTb4b4b4.Te6edf3messageTffd700}Ta5d6ff. Scheduling fallback worker.Ta5d6ff" Tb4b4b4}
Te6edf3scheduleKeepAliveWorkerTb4b4b4(Te6edf3contextTb4b4b4)
Tb4b4b4}
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3contextTb4b4b4.Te6edf3startForegroundServiceTb4b4b4(Te6edf3intentTb4b4b4)
Tb4b4b4}
Tb4b4b4}

Tff7b72private Tff7b72fun Td2a8ffscheduleKeepAliveWorkerTb4b4b4(Te6edf3contextTb4b4b4: Te6edf3ContextTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3request Tff7b72=
Te6edf3OneTimeWorkRequestBuilderTff7b72<Te6edf3ServiceKeepAliveWorkerTff7b72>Tb4b4b4(Tb4b4b4)
Tb4b4b4.Te6edf3setExpeditedTb4b4b4(Te6edf3OutOfQuotaPolicyTb4b4b4.Te6edf3RUN_AS_NON_EXPEDITED_WORK_REQUESTTb4b4b4)
Tb4b4b4.Te6edf3buildTb4b4b4(Tb4b4b4)

Te6edf3WorkManagerTb4b4b4.Te6edf3getInstanceTb4b4b4(Te6edf3contextTb4b4b4)Tb4b4b4.Te6edf3enqueueTb4b4b4(Te6edf3requestTb4b4b4)
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s